# $Id: PKGBUILD 183049 2013-04-17 02:02:04Z allan $
# Maintainer: Allan McRae <allan@archlinux.org>
# Contributor: Andreas Radke <andyrtr@archlinux.org>

pkgname=tar
pkgver=1.26
pkgrel=3
pkgdesc="Utility used to store, backup, and transport files"
arch=('i686' 'x86_64')
url="http://www.gnu.org/software/tar/tar.html"
license=('GPL3')
groups=('base')
depends=('glibc' 'sh')
options=('!emptydirs')
install=tar.install
source=(ftp://ftp.gnu.org/gnu/$pkgname/$pkgname-$pkgver.tar.xz{,.sig}
        tar.1)
md5sums=('0ced6f20b9fa1bea588005b5ad4b52c1'
         '6618d5fe7785e138c27d7d6a24e998b2'
         'e97e7343f4e23724b4c48bca2f033e38')

prepare() {
  cd ${srcdir}/$pkgname-$pkgver

  # fix build failure with glibc-2.16
  sed -i -e '/gets is a/d' gnu/stdio.in.h
}

build() {
  cd ${srcdir}/$pkgname-$pkgver
  ./configure --prefix=/usr --libexecdir=/usr/lib/tar
  make
}

check() {
  cd ${srcdir}/$pkgname-$pkgver
  make check
}
  
package() {
  cd ${srcdir}/$pkgname-$pkgver
  make DESTDIR=${pkgdir} install
  
  # probably needed for compatibility
  install -dm755 ${pkgdir}/bin
  ln -s ../usr/bin/tar ${pkgdir}/bin/tar
  
  install -Dm644 ${srcdir}/tar.1 ${pkgdir}/usr/share/man/man1/tar.1
}
